From b356419a072076eb1ceae3dd73f6391ce5519460 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 10 May 2015 21:34:31 +0200 Subject: StringUtils: Fixed StringSplitWithQuotes(). The function would crash when given a string that started with the delimiter. --- src/StringUtils.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 4adc6a0a0..12bd3ada1 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -150,6 +150,13 @@ AStringVector StringSplitWithQuotes(const AString & str, const AString & delim) while ((cutAt = str.find_first_of(delim, Prev)) != str.npos) { + if (cutAt == Prev) + { + // Empty string due to multiple whitespace / whitespace at the beginning of the input + // Just skip it + Prev = Prev + 1; + continue; + } AString current = str.substr(Prev, cutAt - Prev); if ((current.front() == '"') || (current.front() == '\'')) { -- cgit v1.2.3